<?php 
 include_once dirname(__FILE__)."/config.php";
 class aa_indexation_principal{
		 protected $_resultrequest;
		 protected $_cnn;
		 protected $_code_index;
		 protected $_code_ue;
		 protected $_public_cible;
		 protected $_objectif;
		 protected $_discipline;
		 protected $_description;
		 protected $_cause;
		 protected $_depense;
		 protected $_depense_etablissement;
		 protected $_nature;
		 protected $_titre;
		 protected $_mots_cles;
		 protected $_date_creation;
		 public function get_name_table(){ return "aa_indexation";}
		 public function get_name_code_index(){ return "code_index";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function get_name_public_cible(){ return "public_cible";}
		 public function get_name_objectif(){ return "objectif";}
		 public function get_name_discipline(){ return "discipline";}
		 public function get_name_description(){ return "description";}
		 public function get_name_cause(){ return "cause";}
		 public function get_name_depense(){ return "depense";}
		 public function get_name_depense_etablissement(){ return "depense_etablissement";}
		 public function get_name_nature(){ return "nature";}
		 public function get_name_titre(){ return "titre";}
		 public function get_name_mots_cles(){ return "mots_cles";}
		 public function get_name_date_creation(){ return "date_creation";}
		 public function set_code_index($parametre){  $this->_code_index=$parametre;}	
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_public_cible($parametre){  $this->_public_cible=$parametre;}	
		 public function set_objectif($parametre){  $this->_objectif=$parametre;}	
		 public function set_discipline($parametre){  $this->_discipline=$parametre;}	
		 public function set_description($parametre){  $this->_description=$parametre;}	
		 public function set_cause($parametre){  $this->_cause=$parametre;}	
		 public function set_depense($parametre){  $this->_depense=$parametre;}	
		 public function set_depense_etablissement($parametre){  $this->_depense_etablissement=$parametre;}	
		 public function set_nature($parametre){  $this->_nature=$parametre;}	
		 public function set_titre($parametre){  $this->_titre=$parametre;}	
		 public function set_mots_cles($parametre){  $this->_mots_cles=$parametre;}	
		 public function set_date_creation($parametre){  $this->_date_creation=$parametre;}	
		 public function get_resultrequest(){ return $this->_resultrequest;}
		 public function get_code_index(){ return $this->_code_index;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_public_cible(){ return $this->_public_cible;}
		 public function get_objectif(){ return $this->_objectif;}
		 public function get_discipline(){ return $this->_discipline;}
		 public function get_description(){ return $this->_description;}
		 public function get_cause(){ return $this->_cause;}
		 public function get_depense(){ return $this->_depense;}
		 public function get_depense_etablissement(){ return $this->_depense_etablissement;}
		 public function get_nature(){ return $this->_nature;}
		 public function get_titre(){ return $this->_titre;}
		 public function get_mots_cles(){ return $this->_mots_cles;}
		 public function get_date_creation(){ return $this->_date_creation;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 aa_indexation(
			code_ue,
			public_cible,
			objectif,
			discipline,
			description,
			cause,
			depense,
			depense_etablissement,
			nature,
			titre,
			mots_cles,
			date_creation)
 VALUES(
			'".$this->_code_ue."',
			'".$this->_public_cible."',
			'".$this->_objectif."',
			'".$this->_discipline."',
			'".$this->_description."',
			'".$this->_cause."',
			'".$this->_depense."',
			'".$this->_depense_etablissement."',
			'".$this->_nature."',
			'".$this->_titre."',
			'".$this->_mots_cles."',
			'".$this->_date_creation."')";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_code_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_ue='".$this->_code_ue."'";
}
if(!empty($this->_public_cible)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
public_cible='".$this->_public_cible."'";
}
if(!empty($this->_objectif)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
objectif='".$this->_objectif."'";
}
if(!empty($this->_discipline)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
discipline='".$this->_discipline."'";
}
if(!empty($this->_description)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
description='".$this->_description."'";
}
if(!empty($this->_cause)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
cause='".$this->_cause."'";
}
if(!empty($this->_depense)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
depense='".$this->_depense."'";
}
if(!empty($this->_depense_etablissement)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
depense_etablissement='".$this->_depense_etablissement."'";
}
if(!empty($this->_nature)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nature='".$this->_nature."'";
}
if(!empty($this->_titre)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
titre='".$this->_titre."'";
}
if(!empty($this->_mots_cles)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
mots_cles='".$this->_mots_cles."'";
}
if(!empty($this->_date_creation)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
date_creation='".$this->_date_creation."'";
}
$sql="UPDATE 
aa_indexation SET 
 ".$sql."
								WHERE 1=1  AND code_index ='".$this->_code_index."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
aa_indexation 
 
									WHERE 1=1  AND code_index ='".$this->_code_index."'";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
aa_indexation ";

$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_index,
		code_ue,
		public_cible,
		objectif,
		discipline,
		description,
		cause,
		depense,
		depense_etablissement,
		nature,
		titre,
		mots_cles,
		date_creation
 FROM 
 aa_indexation";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_resultrequest=$this->_cnn->query($sql);
 if(!$this->_resultrequest){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function countRowInTable($constraint="")
{

$sql=" SELECT 
  COUNT(*) AS total 
 FROM 
 aa_indexation ";
	$this->_resultrequest=$this->_cnn->query($sql);
$donnees_total=mysql_fetch_assoc($this->_resultrequest);
return $donnees_total['total'];
}
public function fetch_object(){
$row=mysql_fetch_object($this->_resultrequest);
 if($this->_resultrequest){
 if($row){
		$this->_code_index=$row->code_index;
		$this->_code_ue=$row->code_ue;
		$this->_public_cible=$row->public_cible;
		$this->_objectif=$row->objectif;
		$this->_discipline=$row->discipline;
		$this->_description=$row->description;
		$this->_cause=$row->cause;
		$this->_depense=$row->depense;
		$this->_depense_etablissement=$row->depense_etablissement;
		$this->_nature=$row->nature;
		$this->_titre=$row->titre;
		$this->_mots_cles=$row->mots_cles;
		$this->_date_creation=$row->date_creation;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>